﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace lab5
{
    public partial class addNewElement : Form
    {
        public int getSweetType { get { return comboBox1.SelectedIndex; } }

        public string getSweetName { get { return sweetName.Text; } }
        
        public string getProducerName { get { return producerName.Text; } }

        public string getWeight { get { return weight.Text; } }

        public string getCost { get { return cost.Text; } }

        public string getNumber { get { return number.Text; } }

        Form1 f1 = new Form1();
        
        public addNewElement()
        {
            InitializeComponent();
        }
        
        private void cancelButton_Click(object sender, EventArgs e)
        {
            //
            this.Close();
            //f1.Show();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            sweetName.Enabled = true;
            producerName.Enabled = true;
            weight.Enabled = true;
            cost.Enabled = true;
            number.Enabled = true;
            /*switch (comboBox1.SelectedIndex)
            {
                case 1:
                    
                    break;
                case 2:
                    break;
                case 3:
                    break;
                case 4:
                    break;
                case 5:
                    break;
            }*/
        }

        private void okButton_Click(object sender, EventArgs e)
        {double outd = 0;int outi;
        if ((comboBox1.SelectedIndex >= 0) && (sweetName.Text != "") && (producerName.Text != "") && (double.TryParse(getWeight, out outd)) && (double.TryParse(getCost, out outd)) && (int.TryParse(getNumber, out outi)))
        {
            DialogResult = System.Windows.Forms.DialogResult.Yes;
            //this.Close();
        }
        else
            DialogResult = System.Windows.Forms.DialogResult.No;
        }
    }
}
